import { DisciplineService } from "@/shared/api/api.discipline";
import { QueryClient, useMutation, useQuery } from "@tanstack/react-query";
import { AxiosError } from "axios";



export function useGetDisciplineById(disciplineId: number) {
    const queryClient = new QueryClient
    const { isLoading, error, data, refetch, isSuccess } =
        useQuery(
            {
                queryKey: ['discipline', disciplineId],
                queryFn: () => DisciplineService.getById(disciplineId),
                retry: 3
            }, queryClient
        )
    const errorMessage = error ? "Load disciplines failed" : undefined;

    return {
        isLoading,
        isSuccess,
        errorMessage,
        refetch,
        discipline: data
    };
}